(a) Field
The subject matter disclosed generally relates to computer image rendering. More particularly, the subject matter relates to bilinear filtering.
(b) Related Prior Art
Texture sampling and filtering is a fundamental operation in two-dimensional (2D) and three-dimensional (3D) image rendering. Texture sampling generally consists of reading texture element data (aka texels) from an array (texture) around given sampling coordinates, and filtering it for a smooth appearance.
Typically the texture represents a two-dimensional color image which is mapped onto a 3D object, but there are also applications for non-color data, one-dimensional texture arrays, three-dimensional texture arrays, and six 2D textures arranged into a cube layout.
A common method for performing two-dimensional texture filtering is bilinear filtering. Other well-known techniques include trilinear and anisotropic filtering which use bilinear filtering as a building block to further enhance the filtering quality. One-dimensional, three-dimensional and cube texture filtering are straightforward variations of this method.
It is often required to sample the texture with coordinates that are outside of the texture's dimensions. These so-called addressing modes commonly include wrapping around (or ‘repeating’ the texture), clamping, mirroring once, and mirroring indefinitely. Note that a typical implementation with bilinear filtering requires these addressing modes to be applied to the texels individually to avoid reading outside of the texture data array. Therefore two neighboring texels in the filter kernel are not necessarily neighboring each other in the texture. Therefore they are adjusted to lie within the texture according to at least one given rule.
FIG. 1 illustrates an example of a conventional layout of a two-dimensional texture data in memory. As shown in the layout 100, texels are stored consecutively and at the end of each row (for row-major textures) there can be a padding zone P. The first texel of the next row is stored in the next memory location after the padding zone. Memory uses linear addresses and is thus one-dimensional, but in this illustration each new row is depicted below the previous one to visualize how a two-dimensional texture can be laid out in linear memory. The data size of a row of texels, plus any padding at the end, is the stride value that is the difference between the memory addresses of a texel below another texel.
In conventional methods, when the coordinate of a given sampling point S are adjacent to the border of the data layout as exemplified in FIG. 1, texel data has to be read from the opposite side of the layout to avoid reading non-texel data. For example, as shown in FIG. 1 the sampling point S is in the column (p) on the right edge of the layout, however, in order avoid sampling non-texel data from the padding zone, texel data is sampled from the opposite edge e.g. column (a). This requires a separate memory load operation for each texel to be read. This method is otherwise known as the ‘wrapping’ addressing mode. Implementations using this data layout have to perform extra work to apply the addressing mode to each texel and read each texel individually.
For cube textures, modern 3D graphics APIs also expect that when sampling a location which would result in reading texels for the filter kernel outside of the two-dimensional array of one cube face, the closest texels from the neighboring cube face are read instead. This also results in neighboring texels of the filter kernel not necessarily neighboring each other in the logical texture layout, and thus, requiring additional computing time and memory load operations.
Therefore, there is a need for a system and method which reduce the computation time of bilinear filtering.